Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Provide alternative for NodeDiscriminator::fromNode that doesnt use Nodes content stream #5144

Conversation

mhsdesign
Copy link
Member

Related #5034 and #5043

Upgrade instructions

Review instructions

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@mhsdesign

This comment was marked as outdated.

We cannot rely on $this->currentContentStreamId being the matching one for $this->currentNode, because the step

`I expect a node identified by live-cs-identifier;lady-eleonode-nodesworth;{} to exist in the content graph`

can initialize a foreign node!
@mhsdesign
Copy link
Member Author

Okay so i tried 3 different ways of achieving the goal (not to use $node->subgraphIdentity->contentStreamId) and im now kinda happy with the last attempt of introducing a ContentStreamAwareNode (+ builder) for the tests.

Horray 🥳

@mhsdesign mhsdesign marked this pull request as ready for review June 16, 2024 19:25
@mhsdesign mhsdesign force-pushed the task/dontUseNodesContentStreamIdInNodeDiscriminator branch 2 times, most recently from 0d3bc77 to 6101daf Compare June 16, 2024 19:30
@mhsdesign mhsdesign force-pushed the task/dontUseNodesContentStreamIdInNodeDiscriminator branch from 6101daf to eef4166 Compare June 17, 2024 07:02
@mhsdesign mhsdesign requested review from nezaniel and kitsunet June 17, 2024 09:00
Comment on lines +16 to +17
/** Alias for $currentNode->instance->aggregateId */
public NodeAggregateId $aggregateId,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that way we dont need to rewrite too much code ...

$subgraph = $this->getCurrentSubgraph();

$parent = $subgraph->findParentNode($currentNode->aggregateId);
Assert::assertInstanceOf(Node::class, $parent, 'Parent not found.');
$actualParentDiscriminator = NodeDiscriminator::fromNode($parent);
$actualParentDiscriminator = NodeDiscriminator::fromNode($currentNode->builder()->buildNode($parent));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternative: ... if we dislike the god object

Suggested change
$actualParentDiscriminator = NodeDiscriminator::fromNode($currentNode->builder()->buildNode($parent));
$actualParentDiscriminator = NodeDiscriminator::fromNode(ContentStreamAwareNodeBuilder::fromNode($currentNode)->buildNode($parent));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed not to have this kind of DTOs today (see #5034 (comment))

@mhsdesign
Copy link
Member Author

Closing in favour of #5169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants